﻿using System;
using System.Windows.Data;
using AnthStat.Domain;

namespace AnthStat.WPF.Applications.Converters
{
    public sealed class DataCaptureModeToVisibilityConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            DataCaptureMode mode = (DataCaptureMode)value;

            if (parameter == null)
            {

                if (mode == DataCaptureMode.IndividualAssessments)
                {
                    return System.Windows.Visibility.Visible;
                }
                else
                {
                    return System.Windows.Visibility.Collapsed;
                }
            }
            else
            {
                string objectMode = parameter.ToString();

                if ((objectMode == "IA" && mode == DataCaptureMode.IndividualAssessments) || (objectMode == "NS" && mode == DataCaptureMode.NutritionalSurvey)) 
                {
                    return System.Windows.Visibility.Visible;
                }
                else
                {
                    return System.Windows.Visibility.Collapsed;
                }
            }
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
